#ifndef EVQ_IMPL_H_INCLUDED
#define EVQ_IMPL_H_INCLUDED
/******************************************************************************
* (c)2025 Michael T. Richter
*
* This software is distributed under the terms of WTFPLv2.  The full terms and
* text of the license can be found at http://www.wtfpl.net/txt/copying
******************************************************************************/

typedef struct _evq_event_t
{
    // An event contains within it the time it is to fire, the period in which it
    // re-fires if desired, a callback (either a straight function or a coroutine
    // depending on a flag), a pointer to the next event in the chain, and a
    // pointer to its containing evq_queue_t.  One-use events clean up after
    // themselves while manually-created events need manual lifetime management.

    // timing
    tick_ms  trigger_time;
    delay_ms period;

    // callback
    bool is_coroutine;
    void *data;
    union
    {
        evq_callback cb;
        co_t         co;
    };

    // chaining
    evq_event_t chain;
    evq_queue_t container;

    // book-keeping
    bool reusable;
    bool in_use;
} evq_event_t_impl;

#endif //!EVQ_IMPL_H_INCLUDED
